<?php

namespace app\admin\controller;

use app\BaseController;
use app\common\model\MbtiConfig;

class Conf extends BaseController
{

    /**
     * 配置列表
     * @return \think\response\View
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function index()
    {
        if (request()->isPost()){
            $data = request()->param();
            MbtiConfig::where('id',1)
                ->update($data);
            return toJson(0,'ok',$data);
        }
        $mbtiConfig = MbtiConfig::where('id', 1)
            ->find();
            return view('admin/conf', ['mbti' => $mbtiConfig]);
    }
}